# save_screenshot 保存一张后缀名为png的图片，截图保存在当前代码目录下
import time

from selenium import webdriver
from selenium.webdriver.common.by import By

wd = webdriver.Chrome()
wd.maximize_window()
wd.get("https://cn.bing.com")
wd.find_element(By.ID,"sb_form_q").send_keys("沙")
wd.find_element(By.ID,"search_icon").click()
time.sleep(2)
# 以日期命名截图名称
pic_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(time.time()))

# 截图
wd.save_screenshot(pic_time+".png")
wd.get_screenshot_as_file("a.png")
time.sleep(1)

wd.quit()